import {request} from '@/utils/request'

// 表单查询 参数 code name start pageSize
//"info": [{
//          "id": "int,表单类id",
//          "code": "string,编码",
//          "name": "string,表单名称",
//          "state": "boolean,是否可用",
//          "note": "string,备注说明",
//          "ord": "int,序号"
//      }],
//字段键值对  变量 wpId fieldName param
export function wpselect(param) {
  return request({
    url: '/wp/select',
    method: 'post',
    data: param,
    type: 2
  })
}

export function sqlValue(param) {
  return request({
    url: '/wp/sqlValue',
    method: 'post',
    data: param,
    type: 2
  })
}

// 保存 wpId deptId tables param nodeCode
export function wpsave(param) {
  return request({
    url: '/wp/save',
    method: 'post',
    data: param,
    type: 2
  })
}

//详情 参数 funcId wpId workId param nodeCode
export function wpdetail(param) {
  return request({
    url: '/wp/detail',
    method: 'post',
    data: param,
    type: 2,
    showLoading: 1,
  })
}

//根据sql  查询数据    参数 sql
export function wpgetData(param) {
  return request({
    url: '/wp/getData',
    method: 'post',
    data: param,
    type: 2
  })
}

//根据sql  修改字段值    参数   tableName, qrName, qrCode, keyName, workId
export function wpsaveData(param) {
  return request({
    url: '/wp/saveData',
    method: 'post',
    data: param,
  })
}


//根据sql  修改字段值    参数   wpId, fieldName, param
export function wpgetValue(param) {
  return request({
    url: '/wp/getValue',
    method: 'post',
    data: param,
    type: 2
  })
}

//通用 api 方法
export function execApi(url, param, type = 0) {
  return request({
    url: url,
    method: 'post',
    data: param,
    type: type
  })
}

//附件新增上传
export function uploadImage(param) {
  return request({
    url: '/uploadImage',
    method: 'post',
    showMessage: false,
    data: param,
    type: 1,
  })
}

//附件新增上传
export function fpglreadPic(param) {
  return request({
    url: '/fpgl/readPic',
    method: 'post',
    showMessage: false,
    showLoading: true,
    data: param,
    type: 1,
  })
}


//获取wpId 修改字段值    参数   String tableName, 表名  String keyName, 主键字段名   Integer workId，主键值
export function getWpIdByTable(param) {
  return request({
    url: '/wp/getWpIdByTable',
    method: 'post',
    data: param,
  })
}

export function wpgetDataByPage(param) {
  return request({
    url: 'wp/getDataByPage',
    method: 'post',
    data: param,
    type: 2,
  })
}

export function updateWpVar(param) {
  return request({
    url: 'wp/updateWpVar',
    method: 'post',
    data: param,
    type: 2,
  })
}

export function userDefinedApi(url, method, param, type) {
  return request({
    url: url,
    method: method,
    data: param,
    type: type,
  })
}

// 加人按钮
export function wfSaveUser(param) {
  return request({
    url: '/wf/saveUser',
    method: 'post',
    data: param,
    type: 2,
  })
}